#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
int global_val = 100;

int main()
{
  int cnt = 5;
  pid_t id = fork();
  if(id == 0)
  {
    //child process
    while(1)
    {
      printf("child process, pid=%d, ppid=%d, global_val=%d, &global_val=%p\n", getpid(), getppid(), global_val, &global_val);
    
      if(cnt) cnt--;
      else{
        global_val = 200;
      }
      sleep(1);
    }
  }
  else
  {
    //father process
    while(1)
    {
      printf("father process, pid=%d, ppid=%d, global_val=%d, &global_val=%p\n", getpid(), getppid(), global_val, &global_val);
      sleep(1);
    }
  }
  return 0;
}
